perm filename EADDST.2[EAL,HE]1 blob sn#674813 filedate 1982-09-27 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	{$NOMAIN	Editor: Routine to add a statement }
C00005 00003	(* addStmnt: main body *)
C00027 ENDMK
CāŠ—;
{$NOMAIN	Editor: Routine to add a statement }

%include eedit.hdr;

{ Externally defined routines from elsewhere: }

	(* From EAUX1A *)
procedure borderLines;						external;

	(* From ETOKEN *)
procedure eGetToken;						external;

	(* From EPUTST *)
procedure putstmnt(s: statementp; indent, plevel: integer);	external;

	(* From EAUX3C - addStmnt aux routines *)
procedure addNSt(sty: stmntypes; nextLine: cursorpp;
	var sp: statementp; slabel: varidefp;
	emptyp,stok: boolean; var nogood: boolean);		external;

	(* From the EADDn modules - aux routines *)
procedure addst1(sp: statementp);				external;
procedure addst2 (nextLinep: cursorpp; sp: statementp);		external;
procedure addSetup(nextLinep: cursorpp;
	var emptyp,stok,clok: boolean; var l,elen: integer;
	firstTime: boolean; var echar: ascii);			external;
procedure add1Aux (var l,lcur: integer; nextLinep: cursorpp;
	var sp: statementp; var slabel: varidefp;
	var emptyp,stok,clok,nogood,labp: boolean);		external;
procedure addEndStmnt (nextLinep: cursorpp;
	var nogood,emptyp: boolean; var l,ocur: integer);	external;
procedure add2Aux (nextLinep: cursorpp; var l,ocur,lcur: integer; 
	var nogood: boolean; slabel: varidefp; labp: boolean);	external;
procedure add4Aux (sp: statementp; var lcur,ocur: integer; 
	slabel: varidefp; nextLinep: cursorpp; 
	nogood,emptyp: boolean; var firstTime: boolean);	external;
procedure add1Filler(nextLinep: cursorpp; var l: integer;
	var emptyp,stok,clok,nogood: boolean;
	var sp: statementp; slabel: varidefp);			external;
procedure add3Aux (nextLinep: cursorpp; sp: statementp;
	slabel: varidefp; var emptyp,stok,nogood,labp: boolean;
	var lcur: integer);					external;
procedure addCmon(defer: boolean; nextLinep: cursorpp;
	var sp: statementp; slabel: varidefp;
	emptyp,clok,stok: boolean; var nogood: boolean);	external;

(* addStmnt: main body *)

procedure addStmnt(firstTime: boolean); external;
procedure addStmnt;
 var l,elen,ocur,lcur: integer; nextLine: cursorp;
     sp: statementp; echar: ascii; slabel: varidefp;
     emptyp,stOk,clOk,nogood,again,labp: boolean;

 begin
 setExpr := true;
 echar := chr(15B);
 repeat
  repeat
   newDeclarations := nil;
   sp := nil;
   nogood := false;
   labp := false;
   ocur := cursorLine;
   lcur := ocur;
   addSetup(ref(nextLine),emptyp,stok,clok,l,elen,firstTime,echar);
   slabel := nil;

   with eCurToken do
    begin
    add1Aux (l,lcur,ref(nextLine),sp,slabel,emptyp,stok,clok,nogood,labp);
    if (ttype = reswdtype) and (rtype = stmnttype) then
      begin
      if stmnt = cmtype then	(* Condition monitors are special *)
	addCmon(false,ref(nextLine),sp,slabel,emptyp,clok,stok,nogood)
       else if (stmnt = endtype) or (stmnt = coendtype) then
 	addEndStmnt (ref(nextLine),nogood,emptyp,l,ocur) 	(* END/COEND addition *)
       else	(* A regular kind of statement - add it *)
	begin
	addNSt(stmnt,ref(nextLine),sp,slabel,emptyp,stok,nogood);
	if stOk then
	  if stmnt <= returntype then addst1(sp)
	   else addst2(ref(nextLine),sp);
	end
      end
     else if (ttype = reswdtype) and (rtype = filtype) then
      begin
      if filler in [untltype,dotype,totype,viatype,withtype] then
	add1Filler(ref(nextLine),l,emptyp,stok,clok,nogood,sp,slabel)
       else if filler = defertype then
	begin
	eGetToken;
	if (ttype = reswdtype) and (rtype = stmnttype) and (stmnt = cmtype) 
	  then addCmon(true,ref(nextLine),sp,slabel,emptyp,clok,stok,nogood)
	  else add2Aux(ref(nextLine),l,ocur,lcur,nogood,slabel,labp);
	end
      end
     else add3Aux(ref(nextLine),sp,slabel,emptyp,stok,nogood,labp,lcur);

    add4Aux(sp,lcur,ocur,slabel,ref(nextLine),nogood,emptyp,firstTime);
    end

  until endOfLine;
  flushcomments := true;		(* don't allow comments anywhere else *)

  if ((echar = 'U') or (echar = 'P')) and (not nogood) then
    cursorLine := cursorLine - 2;			(* U or P *)
  again := (echar = 'N') or (echar = 'P');		(* keep going if N or P *)
  firstLine := 0;
  lastLine := -1;
  setCursor := true;
  curLine := 0;
  putStmnt(dProg,0,99);
  setCursor := false
 until not again;

 borderLines;
 setExpr := false;
 end;